{// 引入标签库 }
<tagLib name="html" />
{// 加载头部公共文件 }
<include file="Public:header" />
<style type="text/css">
table.list{width: 1300px;}
    .hide{display: none;}
    .tips{position: absolute;
              padding: 0px 5px;
              border: 3px solid #CCC;
              background: white;
              width: 250px;
              margin-top: -3px;
              z-index: 101;/*防止被其他td遮住*/
              box-shadow: inset 1px 1px 0 rgba(0,0,0,0.1), inset 0 -1px 0 rgba(0,0,0,0.07);
              font-size: 14px;
    }	table.cdl{margin:0px 0px; padding:1px; border-collapse:collapse; border:1px solid gray; text-align:left; width:99%; float:left}
  table.list td{border-left:1px solid silver; border-bottom:1px solid silver; vertical-align:top; padding:0px;}
  th{text-align: center;width:100px;}
  td{width:100px;text-align:center;}

    ul li{display: list-item;list-style: none;}
    
    #dhtmltooltip{
        position: absolute;
        width: 252px;
        visibility: hidden;
        z-index: 100;
    }
</style>
<!-- 菜单区域  -->

<!-- 主页面开始 -->
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
  <div class="panel-header"  onclick="biguse('house_stats')">
    房态管理 
    <font style="background-color:yellow;margin-left: 55px;">口头</font> | <font  style="background-color:red">定金</font> | <font style="background-color:#A8F32A">入住</font>
  </div>
  <div id="house_stats">
<!--  功能组区域  -->
<div class="operate" >
<!-- 查询区域 -->
<div id="dhtmltooltip">
    <ul id="show_tip_85214" class="hide tips">
        <li>mike(mikegao_1)</li>
        <li>入住：2012-06-15 20:01:09</li>
        <li>离开：2012-10-17 20:01:11</li>
        <li>实离：</li>
    </ul>
</div>
<div class="fLeft">
<form method='post' action="__URL__">
<div class="fLeft">
    <span id="key">
        <select name="hotel" style="width:150px;" onchange="modifyHouse(this);">
            <option value="0"><font color="red">--全部公寓--</font></option>
            <volist name="hotel" id="ht">
                <option value="{$ht.id}" <eq name="_POST.hotel" value="$ht.id">selected</eq> >{$ht.name}</option>
            </volist>
            
         </select>
        <php>$house_default=0;//默认全部房型，若选择全部房型，则为0，也在empty判断内</php>
        <empty name="_POST.house_id">
            <php>
                //hotel有post查询
                if(isset($_POST['hotel'])){
                    echo makeSimpleHouse($house_default,$_POST['hotel']);
                }else{
                    echo makeSimpleHouse(1,1);//第一次打开，默认查询圣天地A房型
                }
            </php>
            <else/>
            {$_POST.house_id|makeSimpleHouse=$_POST['hotel']}
        </empty>
        <select type="text" title="选择年" name="year" >
            <?php $t_year =date('Y')+3;
            echo $c_year;
                for($i = (date('Y')-7);$i < $t_year;$i++ ){
            ?>
            <option value="{$i+1}" <eq name="year" value="$i+1">selected</eq> >{$i+1}</option>
            <?php } ?>
        </select>
        <select type="text" title="选择月份" name="month" ><?php for($i =0;$i < 12;$i++ ){ ?>
            <option value="{$i+1}" <eq name="month" value="$i+1">selected </eq> >{$i+1}月</option>
            <?php } ?>
        </select>
    </span>
</div>
<html:imageBtn name="search" type="submit" value="查询" style="impBtn hMargin fLeft shadow" />
<b>租金总额</b>({$rentSum})
    <b>房间数量</b>({$countRooms}) <a href="#" onclick="getFreeDetail()"><b>今日空房</b>({$freeRooms})</a>
</div>
<!-- 高级查询区域 -->
<div  id="searchM" class=" none search cBoth" >
</div>

</form>
</div>
<!-- 功能组区域结束 -->

<!-- 列表显示区域  -->
<div class="list" >

<div id="result" class="result none"></div>

<table id="checkList" class="list" cellpadding="0" cellspacing="0" style="font-size: 12px;table-layout:fixed" >
    <tbody>
        <tr><td height="5" colspan="{$monthCount+2}" class="topTd"></td></tr>		
        {$monthCount,$month|getTitleRow}		
    <volist name="rooms" id="room">
        <if condition="($key eq 10) or ($key eq 20) ">{$monthCount,$month|getTitleRow}</if>
        <tr class="row">			
            <td colspan=2><div> <a style="font-size: 10px;" href="#" title="{$room.room_no},{$room.house_id|getModelName=House},开始:{$room.start_time|toDate='Y-n-d'},到期：{$room.end_time|toDate='Y-n-d'}">{$room.room_no}</a></div></td>
        <if condition="(isMonthCheckin($room['room_id'],$month,$year) neq false) or (isMonthCheckin($room['room_id'],$month,$year,1) neq false)" ><!--入住或预定-->
            <?php for($i =0;$i < $monthCount;$i++ ){
            $checkDetail = isCheckin($room['room_id'],$month,$i+1,$year,0 );
            $reseDetail = isCheckin($room['room_id'],$month,$i+1,$year,1 );
            /*if($i>0){
                 $lastCheckin = isCheckin($room['room_id'],$month,$i,$year,0 );
                 $isSameCheck = ($lastCheckin['id'] == $checkDetail['id'])?true:false;
                 $lastRese = isCheckin($room['room_id'],$month,$i,$year,1 );
                 $isSameRese = ($lastRese['id'] == $reseDetail['id'])?true:false;
                 dump($isSameCheck);
            }*/

            ?>
            <if condition="$checkDetail neq false" > <!--入住-->
                <td   bgcolor="#A8F32A"  style="position: relative;*z-index: <php>echo ($monthCount-$i)</php>	<?php				$date_time_array = getdate (time());							if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)				{					                	echo ";border:1px solid red";                }                                ?>">
                   <a href="__APP__/Checkin/edit/id/{$checkDetail.id}" target="_blank" onmouseover="showDetail({$checkDetail.id}{$i})" onmouseout="hideDetail({$checkDetail.id}{$i})">{$checkDetail.member_id|getModelName='member'|cutstr=6,''}</a>
                   <ul id="show_tip_{$checkDetail.id}{$i}" class="hide tips" >
                       <li>{$checkDetail.member_name}</li>
                       <li>入住：{$checkDetail.start_time|toDate}</li>
                       <li>离开：{$checkDetail.end_time|toDate}</li>
                       <li>实离：{$checkDetail.end_realtime|toDate}</li>
                   </ul>
               
               </td>

            <else /><!--预定-->
            <neq name="reseDetail" value="0" >
                        <eq name="reseDetail.status" value="3">
                            <td bgcolor="red" style="position: relative;*z-index:<php>echo ($monthCount-$i)</php>" >
                                <a href="__APP__/Order/edit/id/{$reseDetail.id}" target="_blank" onmouseover="showDetail({$reseDetail.id}{$i})" onmouseout="hideDetail({$reseDetail.id}{$i})">{$reseDetail.member_id|getModelName=Member}</a>
                                <ul id="show_tip_{$reseDetail.id}{$i}" class="hide tips" >
                                    <li>{$reseDetail.member_id|getModelName=Member}</li>
                                    <li>入住：{$reseDetail.start_time|toDate}</li>
                                   <li>离开：{$reseDetail.end_time|toDate}</li>
                               </ul>
                            </td>
                            <else />
                            <td bgcolor="yellow" style="position: relative;*z-index:<php>echo ($monthCount-$i)</php>" ><!--口头-->
                                <a href="__APP__/Order/edit/id/{$reseDetail.id}" target="_blank" onmouseover="showDetail({$reseDetail.id}{$i})" onmouseout="hideDetail({$reseDetail.id}{$i})">{$reseDetail.member_id|getModelName=Member}</a>
                                <ul id="show_tip_{$reseDetail.id}{$i}" class="hide tips" >
                                   <li>{$reseDetail.member_id|getModelName=Member}</li>
                                   <li>入住：{$reseDetail.start_time|toDate}</li>
                                   <li>离开：{$reseDetail.end_time|toDate}</li>
                               </ul>
                            </td>
                        </eq>
                    <else />
                    <td 				<?php				$date_time_array = getdate (time());							
                    if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)				{					                	echo "style='border:1px solid red'";                }                                ?> >
                        <?php
                         if( (isMaintain($room['room_id'],$month,$i+1,$year,1) == false) && (isMaintain($room['room_id'],$month,$i+1,$year,0) == false) 
                          && mktime(0, 0, 0, date("n"),date("j"),date("Y") ) <= mktime(0, 0, 0, $month,$i+1,$year)
                          && is_available_room($room['room_id'],$year,$month,$i+1)
                           )
               {
               ?>
               <a href="javascript:void(0)" onclick="javascript:opendiag('{$room.room_no}',{$room.room_id},{$i+1} )">开房</a>
              <?php
                } ?>
                    </td>
                </neq>
            </if>
            <?php } ?><!--入住或预定结束-->
            <else /><!--纯空房-->
            <?php for($i =0;$i < $monthCount;$i++ ){ ?>
            <td 	<?php				$date_time_array = getdate (time());							if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)				{					                	echo "style='border:1px solid red'";                }                                ?>>
                <?php
               if( (isMaintain($room['room_id'],$month,$i+1,$year,1) == false) && (isMaintain($room['room_id'],$month,$i+1,$year,0) == false)
                && mktime(0, 0, 0, date("n"),date("j"),date("Y") ) <= mktime(0, 0, 0, $month,$i+1,$year) 
                && is_available_room($room['room_id'],$year,$month,$i+1)
                )
               {
               ?>
               <a href="javascript:void(0)" onclick="javascript:opendiag('{$room.room_no}',{$room.room_id},{$i+1} )">开房</a>
              <?php
                } ?>
            </td>
            <?php } ?>
        </if>
        </tr>
    </volist>	{$monthCount,$month|getTitleRow}
    </tbody>
</table>
<!--今日空房-->
<table id="nowfree" class="list none" cellpadding="0" cellspacing="0" style="font-size: 12px;table-layout:fixed" >
  <tr><td height="5" colspan="{$monthCount+2}" class="topTd"></td></tr>   
        {$monthCount,$month|getTitleRow}  
    <volist name="todayFreeRooms" id="troom">

      <if condition="($key eq 10) or ($key eq 20) ">{$monthCount,$month|getTitleRow}</if>
        <tr class="row">      
            <td colspan=2 style="width:80px;"><div> <a style="font-size: 10px;width:80px;margin:0px 15px;" href="#" title="{$troom.room_no},{$troom.house_id|getModelName=House},开始:{$troom.start_time|toDate='Y-n-d'},到期：{$troom.end_time|toDate='Y-n-d'}">{$troom.room_no}</a></div></td>
        <if condition="(isMonthCheckin($troom['room_id'],$month,$year) neq false) or (isMonthCheckin($troom['room_id'],$month,$year,1) neq false)" ><!--入住或预定-->
            <?php for($i =0;$i < $monthCount;$i++ ){
            $checkDetail = isCheckin($troom['room_id'],$month,$i+1,$year,0 );
            $reseDetail = isCheckin($troom['room_id'],$month,$i+1,$year,1 );
            ?>
            <if condition="$checkDetail neq false" > <!--入住-->
                <td   bgcolor="#A8F32A"  style="position: relative;*z-index: <php>echo ($monthCount-$i)</php> <?php       $date_time_array = getdate (time());              if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)        {                           echo ";border:1px solid red";                }                                ?>">
                   <a href="__APP__/Checkin/edit/id/{$checkDetail.id}" target="_blank" onmouseover="showDetail({$checkDetail.id}{$i})" onmouseout="hideDetail({$checkDetail.id}{$i})">{$checkDetail.member_id|getModelName='member'|cutstr=6,''}</a>
                   <ul id="show_tip_{$checkDetail.id}{$i}" class="hide tips" >
                       <li>{$checkDetail.member_name}</li>
                       <li>入住：{$checkDetail.start_time|toDate}</li>
                       <li>离开：{$checkDetail.end_time|toDate}</li>
                       <li>实离：{$checkDetail.end_realtime|toDate}</li>
                   </ul>
               
               </td>

            <else /><!--预定-->
            <neq name="reseDetail" value="0" >
                        <eq name="reseDetail.status" value="3">
                            <td bgcolor="red" style="position: relative;*z-index:<php>echo ($monthCount-$i)</php>" >
                                <a href="__APP__/Order/edit/id/{$reseDetail.id}" target="_blank" onmouseover="showDetail({$reseDetail.id}{$i})" onmouseout="hideDetail({$reseDetail.id}{$i})">{$reseDetail.member_id|getModelName=Member}</a>
                                <ul id="show_tip_{$reseDetail.id}{$i}" class="hide tips" >
                                    <li>{$reseDetail.member_id|getModelName=Member}</li>
                                    <li>入住：{$reseDetail.start_time|toDate}</li>
                                   <li>离开：{$reseDetail.end_time|toDate}</li>
                               </ul>
                            </td>
                            <else />
                            <td bgcolor="yellow" style="position: relative;*z-index:<php>echo ($monthCount-$i)</php>" ><!--口头-->
                                <a href="__APP__/Order/edit/id/{$reseDetail.id}" target="_blank" onmouseover="showDetail({$reseDetail.id}{$i})" onmouseout="hideDetail({$reseDetail.id}{$i})">{$reseDetail.member_id|getModelName=Member}</a>
                                <ul id="show_tip_{$reseDetail.id}{$i}" class="hide tips" >
                                   <li>{$reseDetail.member_id|getModelName=Member}</li>
                                   <li>入住：{$reseDetail.start_time|toDate}</li>
                                   <li>离开：{$reseDetail.end_time|toDate}</li>
                               </ul>
                            </td>
                        </eq>
                    <else />
                    <td         <?php       $date_time_array = getdate (time());              
                    if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)        {                           echo "style='border:1px solid red'";                }                                ?> >
                        <?php
                         if( (isMaintain($troom['room_id'],$month,$i+1,$year,1) == false) && (isMaintain($troom['room_id'],$month,$i+1,$year,0) == false) 
                          && mktime(0, 0, 0, date("n"),date("j"),date("Y") ) <= mktime(0, 0, 0, $month,$i+1,$year)
                          && is_available_room($troom['room_id'],$year,$month,$i+1)
                           )
               {
               ?>
               <a href="javascript:void(0)" onclick="javascript:opendiag('{$troom.room_no}',{$troom.room_id},{$i+1} )">开房</a>
              <?php
                } ?>
                    </td>
                </neq>
            </if>
            <?php } ?><!--入住或预定结束-->
            <else /><!--纯空房-->
            <?php for($i =0;$i < $monthCount;$i++ ){ ?>
            <td   <?php       $date_time_array = getdate (time());              if($i==$date_time_array[ "mday"]-1 && $date_time_array["mon"]==$month)        {                           echo "style='border:1px solid red'";                }                                ?>>
                <?php
               if( (isMaintain($troom['room_id'],$month,$i+1,$year,1) == false) && (isMaintain($troom['room_id'],$month,$i+1,$year,0) == false)
                && mktime(0, 0, 0, date("n"),date("j"),date("Y") ) <= mktime(0, 0, 0, $month,$i+1,$year) 
                && is_available_room($troom['room_id'],$year,$month,$i+1)
                )
               {
               ?>
               <a href="javascript:void(0)" onclick="javascript:opendiag('{$troom.room_no}',{$troom.room_id},{$i+1} )">开房</a>
              <?php
                } ?>
            </td>
            <?php } ?>
        </if>
        </tr>
    </volist>{$monthCount,$month|getTitleRow}
  </table>
</div>
</div><!--主体内容--->
<!--  分页显示区域 -->
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束下面是对话框 -->
<script src="__PUBLIC__/Js/jquery-1.4.4.min.js"></script>
<css href="__PUBLIC__/Css/ui-base/jquery.ui.all.css" />
<script src="__PUBLIC__/Js/jquery-ui-1.8.11.custom.min.js"></script>
<!--
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
-->
<style>
		label, input.ui-corner-all { display:block; }
		fieldset { padding:0; border:0; margin-top:25px; }
                table thead th{color:black;}
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
		.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<div id="dialog-form2" title="新增">
	<fieldset>
            房间：<input type="text" id="room" name="room" readonly /><br />
            日期：<input type="text" id="day" name="room" readonly /><br /><br /><br /><br />
		<label for="name"><a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="corder" style="float:left;" href="__APP__/Order/add/room_id/id/start_time/">新增预定单</a>
          <a id="ccheckin" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="float:right" href="__APP__/Order/add/room_id/id/start_time/">新增入住单</a>
    </label>
	</fieldset>
</div>
<div id="dialogbox" title="" style="display:none;"><div id="dialogboxInfo" style="padding-top: 20px;"></div></div>
<script>
	$(function() {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
                $( "#dialog-form2" ).dialog({ //根据房间和日期增加入住单或预订单
			autoOpen: false,
			height: 350,
			width: 350,
			modal: true,
			buttons: {
				'取消': function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});

	});
         function opendiag(room,roomid,day){
                   var day = "{$year}-{$month}-"+day;
                    $('#room').attr('value',room);
                    $('#day').attr('value',day);
                    $('#corder').attr('href','__APP__/Order/add/room_id/'+roomid+'/start_time/'+day);
                    $('#ccheckin').attr('href','__APP__/Checkin/add/room_id/'+roomid+'/start_time/'+day);
                    $( "#dialog-form2" ).dialog( "open" );
                }

       
        /***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

    function showDetail(i){
        if (ns6||ie){
            $("#show_tip_"+i).clone().appendTo("#dhtmltooltip");
            $("#show_tip_"+i).show();
            enabletip=true
            return false
        }

    }
        function hideDetail(i){
            $("#dhtmltooltip").empty();
            hideddrivetip()
        }

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

function biguse(element)
{
  
  var d=document.getElementById(element);
  
  if(d.style.display=='block')
  { d.style.display="none";
  }
  else
  { 
    d.style.display="block";
  }
}

function getFreeDetail(){
   var nf=document.getElementById('nowfree');
   var cl=document.getElementById('checkList');
  if(nf.style.display == "block"){
    nf.style.display = "none";
    cl.style.display = "block";
  }else{
    cl.style.display = "none";
    nf.style.display = "block";
  }
}
	</script>
<php>
    function getTitleRow($monthCount,$month){		
        $trStr = "<tr class=\"row\" ><th colspan=2>房间</th>";
            $week= array('日','一','二','三','四','五','六');
            for($i =0;$i < $monthCount;$i++ ){
                $week_en =date("w",mktime(0,0,0,$month,$i+1));
                $week_cn = $week[$week_en];				
				$date_time_array = getdate (time());
				if($i==$date_time_array["mday"]-1 && $date_time_array["mon"]==$month)
				{
					$trStr .="<th style='border:1px solid red;width:120px;'>".($i+1)."/".$week_cn."</th>";
                                }                else                {                	$trStr .="<th>".($i+1)."/".$week_cn."</th>";                }
            }			
        echo $trStr."</tr>";		
    }
</php>